package com.yang.design.create.builder;

import org.apache.commons.lang3.StringUtils;

public class RabbitMQClient {
    private String address;

    private RabbitMQClient(Builder builder) {
        this.address = builder.ip + ":" + builder.port;
    }


    public static class Builder{
        private String ip;
        private String port;

        public Builder setIp(String ip) {
            this.ip = ip;
            return this;
        }

        public Builder setPort(String port) {
            this.port = port;
            return this;
        }

        public RabbitMQClient build(){
            if (StringUtils.isAnyBlank(ip,port)){
                throw new RuntimeException("参数不能为空！");
            }
            return new RabbitMQClient(this);
        }
    }

    @Override
    public String toString() {
        return "RabbitMQClient{" +
                "address='" + address + '\'' +
                '}';
    }
}
